# app.py
from flask import Flask, jsonify, render_template
import collector

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/api/cpu')
def cpu_stats():
    # 返回内存中缓存的CPU数据
    return jsonify(collector.DATA['cpu'])

if __name__ == '__main__':
    collector.start_collector()
    app.run(debug=True)
